#include<vector>
#include<iostream>
using namespace std;

 struct ListNode {
     int val;
     ListNode *next;
      ListNode() : val(0), next(nullptr) {}
      ListNode(int x) : val(x), next(nullptr) {}
      ListNode(int x, ListNode *next) : val(x), next(next) {}
 };

ListNode* reverseList(ListNode* head) {
    if (head == nullptr || head->next == nullptr)
        return head;

    ListNode* newhead = reverseList(head->next);
    head->next->next = head;
    head->next = nullptr;
    return newhead;
}

ListNode* swapPairs(ListNode* head) {
    if (head == nullptr || head->next == nullptr)
        return head;

    ListNode* newhead = swapPairs(head->next->next);
    ListNode* ret = head->next;
    head->next->next = head;
    head->next = newhead;
    return ret;
}

double myPow(double x, int n) {

    int a = n;
    if (n < 0) {
        if (n == -pow(2, 31))
            n = INT_MAX;
        else
            n = -n;
    }

    if (n == 0)
        return 1;

    double ret = myPow(x, n / 2);

    if (a < 0)
    {
        if (a == -pow(2, 31))
            return n % 2 == 0 ? 1 / (ret * ret * x) : 1 / (ret * ret * x * x);
        return n % 2 == 0 ? 1 / (ret * ret) : 1 / (ret * ret * x);
    }

    return n % 2 == 0 ? ret * ret : ret * ret * x;
}

int main()
{
    ListNode* ln1 = new ListNode(1);
    ListNode* ln2 = new ListNode(2);
    ListNode* ln3 = new ListNode(3);
    ListNode* ln4 = new ListNode(4);
    ListNode* ln5 = new ListNode(5);
    ln1->next = ln2;
    ln2->next = ln3;
    ln3->next = ln4;
    ln4->next = ln5;
    reverseList(ln1);
    swapPairs(ln1);
    double a = myPow(2, -2);
    cout << INT_MAX << " " << -INT_MAX;

	return 0;
}